package com.everydayflash.cart.core.util {
	import com.as3dmod.util.Log;
	import com.everydayflash.cart.core.Pixel3D;
	
	import flash.geom.Matrix3D;
	import flash.geom.Vector3D;	

	/**
	 * @author bartekd
	 */
	public class Obj {
		
		private var vrt:Vector.<Pixel3D>;
		
		public function Obj(data:String) {
			var lines:Array = data.split("\n");
			
			vrt = new Vector.<Pixel3D>();
			
			var sm:Matrix3D = new Matrix3D();
			sm.appendScale(90, 90, 90);
			
			for (var i:int = 0; i < lines.length; i++) {
				var line:String = lines[i];
				if(line.charAt(0) == "v") {
					var vv:Array = line.substring(2).split(" ");
					var vt:Vector3D = new Vector3D(parseFloat(vv[0]), parseFloat(vv[1]), parseFloat(vv[2]));
//					vt = sm.transformVector(vt);
					vrt.push(new Pixel3D(vt.x, vt.y, vt.z));
				}
			}
			
			Log.info(this, lines.length + " vertices found.");
		}
		
		public function getVertices():Vector.<Pixel3D> {
			return vrt;
		}
	}
}
